package com.dios.mirage.navigation.popup;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Keypad;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

import com.dios.mirage.component.fields.NavigationScreenPopupField;
import com.dios.mirage.component.fields.NavigationViewPopupField;

public class NavigationPopup extends PopupScreen{
	
	private VerticalFieldManager fieldManager;
	
	public NavigationPopup(Manager delegate){
		super(delegate);
		createGUI();
	}
	
	public void createGUI(){
		fieldManager = new VerticalFieldManager();
		add(fieldManager);
	}

	public void add(final String label, Field field){
		NavigationViewPopupField navigationField = new NavigationViewPopupField(label, field, this);
		fieldManager.add(navigationField);
	}

	public void add(final String label, Screen screen){
		NavigationScreenPopupField navigationField = new NavigationScreenPopupField(label, screen, this);
		fieldManager.add(navigationField);
	}

	protected boolean keyDown(int keycode, int time) {
		if (Keypad.KEY_ESCAPE==Keypad.key(keycode))
			UiApplication.getUiApplication().popScreen(this);
		return true;
	}
	
	

}
